package com.ph.irp.base.voucher.service.impl;

import java.util.List;

import com.ph.irp.base.voucher.dao.PBaseVoucherDAO;
import com.ph.irp.base.voucher.service.VoucherService;
import com.ph.irp.model.PBaseVoucher;

public class VoucherServiceImpl implements VoucherService {

	PBaseVoucherDAO voucherDaoProxy;

	public PBaseVoucherDAO getVoucherDaoProxy() {
		return voucherDaoProxy;
	}

	public void setVoucherDaoProxy(PBaseVoucherDAO voucherDaoProxy) {
		this.voucherDaoProxy = voucherDaoProxy;
	}

	public List<PBaseVoucher> getVoucherList(PBaseVoucher voucherModel)
			throws Throwable {
		// 查询代码和名称都不为空的时候
		if (voucherModel != null && !voucherModel.getVoucherName().equals("")) {
			return voucherDaoProxy.getVoucherByName(voucherModel
					.getVoucherName());
		} else {
			return voucherDaoProxy.getAllVoucherList();
		}
	}

	@Override
	public void addVoucher(PBaseVoucher voucherModel) throws Throwable {
		voucherDaoProxy.addVoucher(voucherModel);
	}

	@Override
	public int deleteVoucher(Integer voucherId) throws Throwable {
		return voucherDaoProxy.deleteVoucher(voucherId);
	}

	@Override
	public void updateVoucher(PBaseVoucher voucherModel) throws Throwable {
		// TODO Auto-generated method stub
		voucherDaoProxy.updateVoucher(voucherModel);
	}

	public PBaseVoucherDAO getVoucherDao() {
		return voucherDaoProxy;
	}

	@Override
	public PBaseVoucher getVoucherById(Integer voucherId) throws Throwable {
		return voucherDaoProxy.getVoucherByID(voucherId);
	}

	@Override
	public List<PBaseVoucher> getByName(String voucherName) throws Throwable {
		// TODO Auto-generated method stub
		return voucherDaoProxy.getVoucherByName(voucherName);
	}
}
